#import "AppDelegate.h"
#import "GeneratedPluginRegistrant.h"
#import "NativeViewController.h"
#import "SyncDatamanager.h"


@implementation AppDelegate

- (BOOL)application:(UIApplication *)application
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [GeneratedPluginRegistrant registerWithRegistry:self];
    
    [SyncDatamanager startHandleSyncDatas];

    FlutterViewController *fvc = (FlutterViewController *)self.window.rootViewController;
    [fvc removeFromParentViewController];
    UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:fvc];
    self.window.rootViewController = nvc;
    [self.window makeKeyAndVisible];
    [self createButton:fvc];

    return [super application:application didFinishLaunchingWithOptions:launchOptions];
}

-(void)createButton:(FlutterViewController *)fvc {
    UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(100, 200, 100, 50)];
    button.backgroundColor = [UIColor cyanColor];
    [button setTitle:@"跳转native" forState:UIControlStateNormal];
    fvc.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
    [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
}

-(void)buttonAction:(UIButton *)button {
    NativeViewController *vc = [[NativeViewController alloc] init];
    vc.view.backgroundColor = [UIColor whiteColor];
    UINavigationController *nvc = (UINavigationController *)self.window.rootViewController;
    [nvc pushViewController:vc animated:YES];
}


@end

